package com.it.paymoney.Service.Impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.it.paymoney.Service.OrderService;
import com.it.paymoney.Vo.PayAsyncVo;
import com.it.paymoney.Vo.PayVo;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;


@Service
public class OrderServiceImpl /*extends ServiceImpl*/ implements OrderService {

    /**
     * 获取当前订单的支付信息
     */
    @Override
    public PayVo getOrderPay(String orderSn) {

        PayVo payVo = new PayVo();
    /*
      //获取订单号   OrderEntity 请按照项目按需处理 谢谢
        OrderEntity orderInfo = this.getOrderByOrderSn(orderSn);
        //保留两位小数点，向上取值
        //订单号获取金额 orderInfo.getPayAmount()
        BigDecimal payAmount = orderInfo.getPayAmount().setScale(2, BigDecimal.ROUND_UP);
        payVo.setTotal_amount(payAmount.toString());
         其他业务...
    */
        return payVo;
    }

    /*
     处理支付宝的支付结果
     */
    @Override
    public String handlePayResult(PayAsyncVo asyncVo) {

        //获取当前状态
        String tradeStatus = asyncVo.getTrade_status();

        if (tradeStatus.equals("TRADE_SUCCESS") || tradeStatus.equals("TRADE_FINISHED")) {
            //支付成功状态->数据库自行选择
            String orderSn = asyncVo.getOut_trade_no(); //获取订单号
          /*
          this.updateOrderStatus(orderSn,OrderStatusEnum.PAYED.getCode(),PayConstant.ALIPAY);
          */
        }
        return "success";
    }

    /**
     * 修改订单状态
     * @param orderSn
     * @param code

    private void updateOrderStatus(String orderSn, Integer code,Integer payType) {

        this.baseMapper.updateOrderStatus(orderSn,code,payType);
    }
     */



}
